﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Finbook.GameApp.Models.V6
{
    public abstract class RoleV6
    {
        public RoleV6(int hp,string name)
        {
            HP = hp;
            MaxHP = hp;
            Name = name;
            Skills = new List<SkillV6>();
        }
        public string Name { get; set; }
        public int HP { get; set; }
        public int MaxHP { get; set; }
        public List<SkillV6> Skills  { get; set; }


        public abstract SkillV6 SelectSkill();
        public virtual void BeHit(SkillV6 skill, RoleV6 from)
        {
            switch (skill.SkillTarget)
            {
                case SkillTarget.Self:
                    switch (skill.SkillType)
                    {
                        case V5.SkillType.Damage:
                            HP -= skill.Num;
                            HP = HP <= 0 ? 0 : HP;
                            CommonConsole.WriteLine($"{Name}:\t误伤自己，受到伤害{skill.Num},当前血量{HP}", ConsoleColor.Blue);
                            break;
                        case V5.SkillType.Heal:
                            HP += skill.Num;
                            HP = HP>= MaxHP? MaxHP : HP;
                            CommonConsole.WriteLine($"{Name}:\t治疗自己，回血{skill.Num},当前血量{HP}", ConsoleColor.Blue);
                            break;
                        case V5.SkillType.State:
                            break;
                        default:
                            break;
                    }
                    break;
                case SkillTarget.Enemy:
                    from.HP -= skill.Num;
                    from.HP = from.HP <= 0 ? 0 : from.HP;
                    CommonConsole.WriteLine($"{Name}:\t被攻击，受到伤害{skill.Num},当前血量{HP}", ConsoleColor.Green);
                    break;
                case SkillTarget.Friend:
                    switch (skill.SkillType)
                    {
                        case V5.SkillType.Damage:
                            HP -= skill.Num;
                            HP = HP <= 0 ? 0 : HP;
                            break;
                        case V5.SkillType.Heal:
                            HP += skill.Num;
                            HP = HP >= MaxHP ? MaxHP : HP;
                            break;
                        case V5.SkillType.State:
                            break;
                        default:
                            break;
                    }
                    break;
                default:
                    break;
            }
        }
    }
}
